
// light position
uniform vec4 lPos;

// normal, light and view vectors in view space
varying vec3 nv, lv, vv;

void
main()
{
    // transform the vertex position and its normal into view (or eye) space
    vec3 pv = vec3(gl_ModelViewMatrix * gl_Vertex);
    nv = gl_NormalMatrix * gl_Normal;

    // light vector (from vertex to light) in view space.
    //lv = vec3((gl_ProjectionMatrix * lPos).xyz - pv);
    lv = vec3((gl_ModelViewMatrix * lPos).xyz - pv);

    // view vector (from vertex to the eye) in view space
    // (in view space the eye is at (0,0,0) )
    vv = -pv;

    gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;
    gl_FrontColor=gl_Color;

    gl_Position =ftransform();
}
